package com.magicsoft.share.presenter.my;

import android.support.annotation.Nullable;

import com.magicsoft.share.base.BasePresenter;
import com.magicsoft.share.bean.my.AlipayParam;
import com.magicsoft.share.bean.my.WxParameter;
import com.magicsoft.share.constant.APIService;
import com.magicsoft.share.constant.SPKey;
import com.magicsoft.share.rx_retrofit_network.location.retrofit.RetrofitUtil;
import com.magicsoft.share.rx_retrofit_network.location.rxandroid.NetWorkTransformer;
import com.magicsoft.share.rx_retrofit_network.location.rxandroid.SimpleObserver;
import com.magicsoft.share.utils.SPUtils;
import com.magicsoft.share.view.my.IGoldNoVipView;

import io.reactivex.annotations.NonNull;

/**
 * @Author hwg
 * @Description：
 * @Date 2018/3/24
 */
public class GoldNoVipPresenter extends BasePresenter<IGoldNoVipView> {

    /**
     * 获取支付宝支付参数
     * @param shareId
     */
    public void getAlipayParam(@Nullable String shareId) {
        RetrofitUtil.getApi(APIService.class)
                .getAlipayParam(shareId, SPUtils.getInstance().getLong(SPKey.ID))
                .compose(new NetWorkTransformer<AlipayParam>())
                .subscribe(new SimpleObserver<AlipayParam>(mCompositeDisposable) {
                    @Override
                    public void call(@NonNull AlipayParam alipayParam) {
                        getView().getAlipayParamSuccess(alipayParam);
                    }
                });
    }

    public void getWechatPayParam(@Nullable String shareId){
        RetrofitUtil.getApi(APIService.class)
                .getWechatPayParam(shareId, SPUtils.getInstance().getLong(SPKey.ID))
                .compose(new NetWorkTransformer<WxParameter>())
                .subscribe(new SimpleObserver<WxParameter>(mCompositeDisposable) {
                    @Override
                    public void call(@NonNull WxParameter wxParameter) {
                        getView().getWechatPaySuccess(wxParameter);
                    }
                });
    }

    public void getCheckQXCode(@Nullable String qxcode){
        RetrofitUtil.getApi(APIService.class)
                .checkQXCode(qxcode)
                .compose(new NetWorkTransformer<Boolean>())
                .subscribe(new SimpleObserver<Boolean>(mCompositeDisposable) {
                    @Override
                    public void call(Boolean aBoolean) {
                        getView().checkQxcode(aBoolean);
                    }
                });
    }

}
